import request from "@/utils/request";

// 查询生产工单列表
export function listWorkorder(query) {
  return request({
    url: "/mes/pro/workorder/list",
    method: "get",
    params: query,
  });
}

// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: "/mes/pro/workorder/" + workorderId,
    method: "get",
  });
}

// 查询生产工单，并携带每个生产工单下生产任务的情况
export function listWithTaskJson(query) {
  return request({
    url: "/mes/pro/workorder/listWithTaskJson",
    method: "get",
    params: query,
  });
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: "/mes/pro/workorder",
    method: "post",
    data: data,
  });
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: "/mes/pro/workorder",
    method: "put",
    data: data,
  });
}

// 删除生产工单
export function delWorkorder(workorderId) {
  return request({
    url: "/mes/pro/workorder/" + workorderId,
    method: "delete",
  });
}

// 查询物料依赖列表
export function listItems(query) {
  return request({
    url: "/mes/pro/workorder/listItems",
    method: "get",
    params: query,
  });
}

export function dofinish(workorderId) {
  return request({
    url: "/mes/pro/workorder/" + workorderId,
    method: "put",
  });
}
// 多选导出流转卡
export function exportPdf(workorderIds) {
  return request({
    url: "/mes/pro/workorder/exportPdf",
    method: "get",
    params: workorderIds,
  });
}

// 多选下载
export function exportPdfDownload(query) {
  return request({
    url: "/common/download",
    method: "get",
    params: query,
  });
}
// 单个查看流转卡
export function findworkOrderDetail(query) {
  return request({
    url: "/mes/pro/workorder/findworkOrderDetail",
    method: "get",
    params: query,
  });
}
// 创建工单，选择工艺
export function prorouteList(query) {
  return request({
    url: "/mes/pro/proroute/list",
    method: "get",
    params: query,
  });
}
// 销售订单
export function findOrderList(query) {
  return request({
    url: "/mes/erpSaleOrder/findOrderList",
    method: "get",
    params: query,
  });
}
// 销售订单 展开行
export function findItemByCode(query) {
  return request({
    url: "/mes/erpSaleOrder/findItemByCode",
    method: "get",
    params: query,
  });
}
// 销售订单 生成订单
export function addFromErpOrder(query) {
  return request({
    url: "/mes/pro/workorder/addFromErpOrder",
    method: "post",
    params: query,
  });
}
// 查询子级
export function getChildList(query) {
  return request({
    url: "/mes/pro/workorder/getChildList",
    method: "get",
    params: query,
  });
}
// 订单回溯
export function orderZhuisuList(query) {
  return request({
    url: "/mes/pro/orderZhuisu/list",
    method: "get",
    params: query,
    data: query,
  });
}
export function tou(query) {
  return request({
    url: "/mes/pro/feedback/findTableHead",
    method: "get",
    params: query,
    data: query,
  });
}
export function genCode(ruleCode) {
  return request({
    url: "/system/autocode/get/" + ruleCode,
    method: "get",
  });
}
export function listAllUnitmeasure() {
    return request({
      url: '/mes/md/unitmeasure/selectall',
      method: 'get'
    })
  }